using System.Web.Core;

namespace Forum.Business
{
    public class BusinessManager
    {
        private static EntityEngine entityEngine = new EntityEngine();

        #region Group

        public static void CreateGroup(Group group)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildAddGroupRequest(group));
        }
        public static Group GetGroup(int groupId)
        {
            return entityEngine.ExecuteRequest(RequestHelper.BuildGetGroupRequest(groupId)).Reply as Group;
        }
        public static void UpdateGroup(Group group)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildUpdateGroupRequest(group));
        }
        public static void DeleteGroup(int groupId)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildDeleteGroupRequest(groupId));
        }

        #endregion

        #region Section

        public static void CreateSection(Section section)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildAddSectionRequest(section));
        }
        public static Section GetSection(int sectionId)
        {
            return entityEngine.ExecuteRequest(RequestHelper.BuildGetSectionRequest(sectionId)).Reply as Section;
        }
        public static void UpdateSection(Section section)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildUpdateSectionRequest(section));
        }
        public static void DeleteSection(int sectionId)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildDeleteSectionRequest(sectionId));
        }

        #endregion

        #region SectionRoleUser

        public static void CreateSectionRoleUser(SectionRoleUser sectionRoleUser)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildAddSectionRoleUserRequest(sectionRoleUser));
        }
        public static void DeleteSectionRoleUser(int sectionId, int roleId, int userId)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildDeleteSectionRoleUserRequest(sectionId, roleId, userId));
        }

        #endregion

        #region Thread

        public static EntityList GetThreads(BaseRequestBinder requestBinder)
        {
            return entityEngine.ExecuteRequest(requestBinder).Reply as EntityList;
        }
        public static void CreateThread(Thread thread)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildAddThreadRequest(thread));
        }
        public static Thread GetThread()
        {
            return entityEngine.ExecuteRequest(RequestHelper.BuildGetThreadRequest()).Reply as Thread;
        }
        public static Thread GetThread(int threadId)
        {
            return entityEngine.ExecuteRequest(RequestHelper.BuildGetThreadRequest(threadId)).Reply as Thread;
        }
        public static void UpdateThread(Thread thread)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildUpdateThreadRequest(thread));
        }
        public static void DeleteThread(int threadId)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildDeleteThreadRequest(threadId));
        }

        #endregion

        #region Post

        public static void CreatePost(Post post)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildAddPostRequest(post));
        }
        public static Post GetPost(int postId)
        {
            return entityEngine.ExecuteRequest(RequestHelper.BuildGetPostRequest(postId)).Reply as Post;
        }
        public static EntityList GetPostList()
        {
            return entityEngine.ExecuteRequest(RequestHelper.BuildGetPostListRequest()).Reply as EntityList;
        }
        public static void UpdatePost(Post post)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildUpdatePostRequest(post));
        }
        public static void DeletePost(int postId)
        {
            entityEngine.ExecuteRequest(RequestHelper.BuildDeletePostRequest(postId));
        }

        #endregion
    }
}